<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="/js/jquery-3.3.1.js"></script>
</head>

<body>
    <h1>这是登录页面</h1>
    <label>姓名：</label><input type="text" name="name" id="name" />
    <label>密码：</label><input type="password" name="password" id="password" />
    <input type="button" id="btn" value="提交" />
    <script>
        $(document).ready(function () {
            $("#btn").click(function () {


                $.ajax({
                    url: "/login",
                    type: "POST",
                    data: {
                        name: document.getElementById("name").value,
                        password: document.getElementById("password").value
                    },
                    success: function (xhr, data, status) {
                        if (xhr == "登录成功") {
                            window.location.href = "http://localhost:8080/index";
                        }
                    },
                    error: function (data) {
                        console.log(data)
                    }
                })
            })

        })
    </script>
</body>

</html>